<?php 
echo "<h1>Enquiry</h1>";
$objEnquiryForm = new BM_PHPForm();
$firstname = $objEnquiryForm->arrPostData['firstname'];
$lastname = $objEnquiryForm->arrPostData['lastname'];
$phone = $objEnquiryForm->arrPostData['phone'];
$email = $objEnquiryForm->arrPostData['email'];
$subject = $objEnquiryForm->arrPostData['subject'];
$message = $_POST['message']; 

if ($objEnquiryForm->IsPost()) {
	$objEnquiryForm->ChEmptiness("email"	, "Email is empty.");
	$objEnquiryForm->ChWithRegex("email", "Email is Invalid.", "/^[a-z0-9_\\.\\-]+@+[a-z0-9_\\.\\-]+(\\.[a-z]{2,4})$/");
	if ($objEnquiryForm->IsValid()){
		$objMail = $GLOBALS['objMAIL'];
		
		$topic = $subject;
		$topic .= "sent by: ".$firstname . " " . $lastname;
		$text = $message;
		$text .= "\n sent by: ".$firstname . " " . $lastname;
		$text .= "\n phone number :".$phone;
		$text .= "\n email :".$email;
		
		$headers['From']    = $email;
		$headers['Subject'] = $topic;

		$send = $objMail->send($recipients, $headers, $text);
		if (PEAR::isError($send)) { print($send->getMessage());} 
		$objEnquiryForm->SetInfor("submit", "Enquiry form submited successfully! by email=[$email]");
		$firstname = "";
		$lastname = "";
		$phone = "";
		$email = "";
		$subject = "";
		$message ="";
	}
}


?>
<table WIDTH="780" cellpadding="0" cellspacing="0" > 
	<tr>
	<td ALIGN=LEFT valign="top" bgcolor="#f9f9f9" width="80">
	<p>&nbsp; </p>
	<div align="center"><img  style="border:1em" alt="enquiry2" src="img/enquiry_icon2.gif"></div>
	</td>
    <td valign="middle" width="350" bgcolor="#f9f9f9">
<?php 
	print $objEnquiryForm->InfMsgs();
	print $objEnquiryForm->errMsgs();
	print $objEnquiryForm->Open("enquiryform", "Enquiry Form");
	print $objEnquiryForm->HiddenField("action" ,"$action");
	print $objEnquiryForm->HiddenField("entity","$entity");
?>        
        - First Name:<br>
        <input id="firstname" name="firstname" type="text" value="<?php echo $firstname;?>" class="normal" />

        <br/>- Last Name: <br>
        <input id="lastname" name="lastname" type="text" value="<?php echo $lastname;?>" class="normal" />

        <br/>- Phone no: <br>
        <input id="phone" name="phone" type="text" value="<?php echo $phone;?>" class="normal" />

        <br/>- Your Email:<br>
        <input id="email" name="email" type="text" value="<?php echo $email;?>" class="normal" />

        <br/>- Subject:<br>
        <input id="subject" name="subject" type="text" value="<?php echo $subject;?>" class="normal" />
        
        <br/>- Message: <br>
        <textarea NAME="message" ROWS="10" COLS="35"><?php echo $message?></textarea><p>

        <input id="submit" type="submit" value=" Send " />
        <input id="rest" type="reset" value=" Reset " />
        
<?php 
print $objEnquiryForm->close();
?>        
    </td>
    <td ALIGN=LEFT valign="middle" bgcolor="#f9f9f9">&nbsp;</td>
    <td ALIGN=LEFT valign="middle" bgcolor="#f1f1f1" width="350px"><div align="center"><img  style="border:1em" alt="carbrands" src="img/carbrands.jpg"></div></td>
  </tr> 
</table>